﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
	<head>
	<base href="<%=basePath%>">
	<!-- jsp文件头和头部 -->
	<%@ include file="../main/main_top.jsp"%> 
	</head> 
<body>
<div class="container-fluid" id="main-container">
	<div id="page-content" class="clearfix">
		<div class="row-fluid">
				<!-- 检索  -->
				<form action="tableConstants/listTableConstantsData.do" method="post" name="tableConstantsForm" id="tableConstantsForm">
				<input type="hidden" name="currentselecttableconstantsid" id="currentselecttableconstantsid" value="${pageData.currentselecttableconstantsid }"/>
				<input type="hidden" name="org_id" id="org_id" value="${pageData.org_id }"/>
				<table id="table_report" class="table table-striped table-bordered table-hover">
					<thead>
						<tr>
							<th>序号</th>
							<th>类型名称</th>
							<th>上级类型</th>
							<th><i class="icon-time hidden-phone"></i>创建时间</th>
							<th>创建人</th>
							<th class="center">操作</th>
						</tr>
					</thead>
					<tbody>
						
					<!-- 开始循环 -->	
					<c:choose>
						<c:when test="${not empty tableConstantsList}">
							<c:forEach items="${tableConstantsList}" var="tableConstants" varStatus="vs">
								<tr>
									<td class='center' style="width: 30px;">${vs.index+1}</td>
									<td>${tableConstants.type_name }</td>
									<td>${tableConstants.parent_type_name }</td>
									<td><fmt:formatDate value="${tableConstants.create_time}" pattern="yyyy/MM/dd HH:mm:ss" /></td>
									<td>${tableConstants.creator_name}</td>
									<td style="width: 60px;">
										<div class='hidden-phone visible-desktop btn-group'>
											<a class='btn btn-mini btn-info' title="编辑" onclick="editTableConstants('${tableConstants.id }');"><i class='icon-edit'></i></a>
										 	<a class='btn btn-mini btn-danger' title="删除" onclick="delTableConstants('${tableConstants.id }','${tableConstants.type_name }');"><i class='icon-trash'></i></a>
										</div>
									</td>
								</tr>
							</c:forEach>
						</c:when>
						<c:otherwise>
							<tr class="main_info">
								<td colspan="14" class="center">没有相关数据</td>
							</tr>
						</c:otherwise>
					</c:choose>
					</tbody>
				</table>
				
			<div class="page-header position-relative">
				<table style="width:100%;">
					<tr>
						<td style="vertical-align:top;">
							<a class="btn btn-small btn-success" onclick="addTableConstants('${pageData.currentselecttableconstantsid }','${pageData.org_id }');">新增</a>
						</td>
						<td style="vertical-align:top;"><div class="pagination" style="float: right;padding-top: 0px;margin-top: 0px;">${page.pageStr}</div></td>
					</tr>
				</table>
			</div>
			</form>
		<!-- PAGE CONTENT ENDS HERE -->
	  </div><!--/row-->
	</div><!--/#page-content-->
</div><!--/.fluid-container#main-container-->
		<!-- 返回顶部  -->
		<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
			<i class="icon-double-angle-up icon-only"></i>
		</a>
		
		<!-- 引入 -->
		<script type="text/javascript" src="static/1.9.1/jquery.min.js"></script>
		<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
		<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
		<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
		<script type="text/javascript" src="static/js/ace.min.js"></script>
		
		<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
		<!-- 引入 -->
		
		<!--引入弹窗组件start-->
		<script type="text/javascript" src="plugins/attention/zDialog/zDrag.js"></script>
		<script type="text/javascript" src="plugins/attention/zDialog/zDialog.js"></script>
		<!--引入弹窗组件end-->
		
		<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 下拉框 -->
		<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
		<!-- 引入 -->
		
		<script type="text/javascript" src="static/js/jquery.tips.js"></script><!--提示框-->
		<script type="text/javascript">
		
		//$(window.parent.hangge());
		$(top.hangge());
		
		//新增
		function addTableConstants(currentselecttableconstantsid, org_id){
			 //window.parent.jzts();
			 hasTableConstantsById(currentselecttableconstantsid, org_id);
		}
		
		//判断机构名称是否存在
		function hasTableConstantsById(currentselecttableconstantsid, org_id){
			var url = "<%=basePath%>/tableConstants/hasTableConstantsById.do?table_constants_id="+currentselecttableconstantsid;
			$.get(url,function(data){
				if(data=="error"){
					alert("此类型不存在或已被删除");
					return false;
				}else{
					 top.jzts();
					 var diag = new top.Dialog();
					 diag.Drag=true;
					 diag.Title ="新增";
					 diag.URL = '<%=basePath%>/tableConstants/goAddTableConstants.do?currentselecttableconstantsid=' + currentselecttableconstantsid + '&org_id=' + org_id;
					 diag.Width = 410;
					 diag.Height = 260;
					 diag.CancelEvent = function(){ //关闭事件
						 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
							 if('${page.currentPage}' == '0'){
								 top.jzts();
								 setTimeout("self.location.reload()",100);
							 }else{
								 nextPage(${page.currentPage});
							 }
						}
						diag.close();
					 };
					 diag.show();
				}
			});
		}
		
		//修改
		function editTableConstants(table_constants_id){
			 //window.parent.jzts();
			 top.jzts();
			 var diag = new top.Dialog();
			 diag.Drag=true;
			 diag.Title ="修改";
			 diag.URL = '<%=basePath%>/tableConstants/goEditTableConstants.do?table_constants_id=' + table_constants_id;
			 diag.Width = 410;
			 diag.Height = 260;
			 diag.CancelEvent = function(){ //关闭事件
				 if(diag.innerFrame.contentWindow.document.getElementById('centerOfMainFrame').style.display == 'none'){
					nextPage(${page.currentPage});
				}
				diag.close();
			 };
			 diag.show();
		}
		
		//删除
		function delTableConstants(table_constants_id, msg){
			bootbox.confirm("确定要删除["+msg+"]吗?", function(result) {
				if(result) {
					var url = "<%=basePath%>tableConstants/deleteTableConstants.do?table_constants_id=" + table_constants_id +"&tm="+new Date().getTime();
					$.get(url,function(data){
						if(data=="success"){
							nextPage(${page.currentPage});
						}else if(data=="error"){
							bootbox.dialog("删除失败，请先删除此类型下的所有子类型!", [ {
								"label" : "关闭",
								"class" : "btn-small btn-success",
								"callback" : function() {
									//Example.show("great success");
								}
							} ]);
						}
					});
				}
			});
		}
		</script>
		
		<script type="text/javascript">
		$(function() {
			//下拉框
			$(".chzn-select").chosen(); 
			$(".chzn-select-deselect").chosen({allow_single_deselect:true}); 
		});
		</script>
	</body>
</html>